package com.example.first;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListAdapter;
import android.widget.ProgressBar;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import java.util.List;

public class RateListActivity2 extends AppCompatActivity {
    Handler handler;
    String TAG="RateActivity";
    private ProgressBar bar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); setContentView(R.layout.activity_rate_list);
        GridView mylist = findViewById(R.id.mylistview);
        bar=findViewById(R.id.progressBar);
        mylist.setEmptyView(bar);
        handler = new Handler(Looper.myLooper()) {
            @Override
            public void handleMessage(@NonNull Message msg) {
                if (msg.what == 5) {
                    List<String> list2=(List<String>) msg.obj;
                    ListAdapter adapter = new ArrayAdapter<String>(RateListActivity2.this, android.R.layout.simple_list_item_1,list2);
                    mylist.setAdapter(adapter);
                    mylist.setEmptyView(findViewById(R.id.nodata));
                }
                super.handleMessage(msg);
            }
        };
        MyTask mytask=new MyTask();
        mytask.setHandler(handler);
        Thread t = new Thread(mytask);
        t.start();
    }
}